package jdbc.lessen02;

import jdbc.lessen02.util.JdbcUtil;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * @Package lessen02
 * @Author shimmer
 * @Date 2020/7/31 11:39
 * @TODO
 */
public class TestSelect {
    public static void main(String[] args) {
        ResultSet rs = null;
        Statement st = null;
        Connection conn = null;
        try {
            conn = JdbcUtil.getConnection();
            st = conn.createStatement();

            String sql = "select * from `user`";
            rs = st.executeQuery(sql);
            while (rs.next()) {
                System.out.println(rs.getInt(1));
                System.out.println(rs.getString(2));
                System.out.println(rs.getString(3));
                System.out.println("========================");
            }

        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            JdbcUtil.release(rs, st, conn);
        }
    }
}
